/*
    11. Write a program in C to copy a file in another name. 

    Assume that the content of the file test.txt is :                                                                       
    test line 1                                                                                                   
    test line 2                                                                                                   
    test line 3                                                                                                   
    test line 4                                                                                                   
    Test Data :
    Input the source file name : test.txt
    Input the new file name : test1.txt
    Expected Output :

    The file test.txt  copied successfully in the file test1.txt.
    If you read the new file you will see the content of the file :

    test line 1                                                                                                   
    test line 2                                                                                                   
    test line 3                                                                                                   
    test line 4
*/

#include <stdio.h>

#define MAX_STR 1024

int main(void)
{
    FILE *fp1, *fp2;
    char str[MAX_STR];
    char sfname[64];
    char nfname[64];
    
    printf("Input the source file name : ");
    gets(sfname);
    printf("Input the new file name : ");
    gets(nfname);

    fp1 = fopen(sfname, "r");
    fp2 = fopen(nfname, "w+");

    while(fgets(str, MAX_STR, fp1)){
        fputs(str, fp2);
    }

    return 0;
}